# coding: utf-8

def test_block(&block)
	puts block.class
	block.call()
	block.call()
end

test_block { puts "段光伟" }

def test_block()
	puts block_given?
	yield
	yield
end

test_block { puts "段光伟" }

multiply = Proc.new { | a, b | puts a * b }
multiply.call( 3, 4 )

my_puts = Proc.new { |x| puts x }
(1..3).each(&my_puts)


def return_from_proc
	ruby_proc = Proc.new { return "return from a Proc" }
	ruby_proc.call
    return "The function will NOT reach here because a Proc containing a return statement has been called"
end

def return_from_lambda
	ruby_lambda = lambda { return "return from lambda" }
	ruby_lambda.call
	return "The function will reach here"
end

puts return_from_proc
puts return_from_lambda